#region

using System;

#endregion

namespace SmartMathLibrary.QuadPack
{
    /// <summary>
    /// For further information view the QuadPack documentation.
    /// </summary>
    [Serializable]
    public static class DqwgtClass
    {
        /// <summary>
        /// For further information view the QuadPack documentation.
        /// </summary>
        /// <param name="x">The x parameter.</param>
        /// <param name="c">The c parameter.</param>
        /// <param name="p2">The p2 parameter.</param>
        /// <param name="p3">The p3 parameter.</param>
        /// <param name="p4">The p4 parameter.</param>
        /// <param name="kp">The kp parameter.</param>
        /// <returns>For further information view the QuadPack documentation.</returns>
        public static double Dqwgtc(double x, double c, double p2, double p3, double p4, int kp)
        {
            return 1.0 / (x - c);
        }

        /// <summary>
        /// For further information view the QuadPack documentation.
        /// </summary>
        /// <param name="x">The x parameter.</param>
        /// <param name="omega">The omega parameter.</param>
        /// <param name="p2">The p2 parameter.</param>
        /// <param name="p3">The p3 parameter.</param>
        /// <param name="p4">The p4 parameter.</param>
        /// <param name="wgtfunc">The wgtfunc parameter.</param>
        /// <returns>For further information view the QuadPack documentation.</returns>
        public static double Dqwgto(double x, double omega, double p2, double p3, double p4, int wgtfunc)
        {
            double omx;

            omx = omega * x;
            if (wgtfunc == 1)
            {
                return Math.Cos(omx);
            }
            else
            {
                return Math.Sin(omx);
            }
        }

        /// <summary>
        /// For further information view the QuadPack documentation.
        /// </summary>
        /// <param name="x">The x parameter.</param>
        /// <param name="a">The a parameter.</param>
        /// <param name="b">The b parameter.</param>
        /// <param name="alpha">The alpha parameter.</param>
        /// <param name="beta">The beta parameter.</param>
        /// <param name="wgtfunc">The wgtfunc parameter.</param>
        /// <returns>For further information view the QuadPack documentation.</returns>
        public static double Dqwgts(double x, double a, double b, double alpha, double beta, int wgtfunc)
        {
            double bmx;
            double xma;
            double result;

            xma = x - a;
            bmx = b - x;
            result = Math.Pow(xma, alpha) * Math.Pow(bmx, beta);
            switch (wgtfunc)
            {
                case 1:
                    return result;
                case 2:
                    return result * Math.Log(xma);
                case 3:
                    return result * Math.Log(bmx);
                case 4:
                    return result * Math.Log(xma) * Math.Log(bmx);
                default:
                    return result;
            }
        }
    }
}